from django.shortcuts import render
from django.views.generic import View
from apps.commonapp.models import School,Company
from apps.resp.response import Response
from apps.resp.response import PARAMS_ERROR

class SchoolView(View):
    def post(self,req):
        name = req.POST.get("name")
        detail = req.POST.get("detail")
        logo = req.POST.get("logo")
        if logo == "":
            raise PARAMS_ERROR
        School.objects.create(name=name,detail=detail,logo=logo)
        return Response.SUCCESS()

class CompanyView(View):
    def post(self,req):
        name = req.POST.get("name")
        detail = req.POST.get("detail")
        logo = req.POST.get("logo")
        if logo == "":
            raise PARAMS_ERROR
        Company.objects.create(name=name,detail=detail,logo=logo)
        return Response.SUCCESS()